/* eslint-disable no-undef */

let instance = axios.create(); // 创建 axios 实例(主要作用放在与别人配置冲突覆盖)

instance.defaults.baseURL = "http://127.0.0.1:8888"; // 请求基础路径
instance.defaults.headers["Content-Type"] = "multipart/form-data";

instance.defaults.transformRequest = (data, headers) => {
  const contentType = headers["Content-Type"]; // 获取类型
  if (contentType === "application/x-www-form-urlencoded")
    return Qs.stringify(data);
  return data;
};

// 响应拦截
instance.interceptors.response.use((response) => {
  return response.data;
});
